versionNo: [ { validator: validateVersionNo, trigger: 'blur'}

    ],
    
    

var validateVersionNo = (rule, value, callback) => {

  if(value==''){
     callback(new Error('请输入版本号'))
  }
  if(this.listType==5){
    self.checkVersionNo(callback)
  }else{
    if(/^\d{1,3}\.\d{1,3}.\d{1,3}.\d{1,3}$/.test(value) == false){
            callback(new Error("请输入正确格式的版本号"));
        }else{
            self.checkVersionNo(callback)
        }
    }    
}

checkVersionNo (callback) {

  var self = this
  // 获取tag数据
  this.axios
    .post(self.publicPath + '/cversion/checkVersionNo/', {
      componentId: self.form.componentId,
      versionNo: self.form.versionNo
    })
    .then(function (res) {
      if (res.data.code == 1) {
        if (res.data.data == false) {
          callback(new Error('版本号已存在'))
          return
        }
      }
      callback()
    })
    .catch(function (error) {
      console.log(error)
      callback()
    })
},

HappyCodingTop
526 声望847 粉丝

Talk is cheap, show the code!!